% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fips_bgs_in_fips.R
\name{fips_bgs_in_fips}
\alias{fips_bgs_in_fips}
\title{FIPS - Get unique blockgroup fips in or containing specified fips of any type}
\usage{
fips_bgs_in_fips(fips)
}
\arguments{
\item{fips}{vector of US FIPS codes, as character or numeric,
with or without their leading zeroes, each with as many characters}
}
\value{
vector of blockgroup FIPS (or NA values) that may be much longer than the
vector of fips passed to this function.
}
\description{
Convert any FIPS codes to the FIPS of all the blockgroups that are
among or within or containing those FIPS
}
\details{
This is a way to get a list of blockgroups, specified by state/county/tract or even block.

Takes a vector of one or more FIPS that could be State (2-digit), County (5-digit),
Tract (11-digit), or blockgroup (12 digit), or even block (15-digit fips).

Returns unique vector of FIPS of all US blockgroups (including DC and Puerto Rico)
that contain any specified blocks, are equal to any specified blockgroup fips,
or are contained within any provided tract/county/state FIPS.
}
\examples{

  # all blockgroups in one state
  fips_counties_from_state_abbrev("DE")
  fips_bgs_in_fips( fips_counties_from_state_abbrev("DE") )

  blockgroupstats[,.N,by=substr(bgfips,1,2)]
  length(fips_bgs_in_fips("72"))

  # all blockgroups in this one county
  fips_bgs_in_fips(30001)
  fips_bgs_in_fips("30001")
  fips_bgs_in_fips(fips_counties_from_statename("Rhode Island")[1])

  # all blockgroups that contain any of these 6 blocks (i.e., just one bg)
  ## dataload_from_pins("blockid2fips") # very large file to avoid using unless essential
  ## x = blockid2fips$blockfips[1:6] 
  x = c("010010201001000", "010010201001001", "010010201001002",
   "010010201001003", "010010201001004", "010010201001005")
  fips_bgs_in_fips(x)

  # 2 counties
  fips_bgs_in_fips(c(36009,36011))

}
\seealso{
\code{\link[=fips_lead_zero]{fips_lead_zero()}}
}
\keyword{internal}
